package com.and.xmppsdk.fragment.panel;

import com.and.xmppsdk.R;
import com.and.xmppsdk.XmppApplication;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

public class ExitPanel extends OptionPanel implements OnClickListener {

	private static ExitPanel mPanel;

	public static ExitPanel getInstance() {
		mPanel = new ExitPanel();
		return mPanel;
	}

	public ExitPanel() {
	}

	private Button btn_add;
	private Button btn_back;
	private Button btn_logout;
	private View rootView;
	@Override
	public void onActivityCreated(Bundle arg0) {
		super.onActivityCreated(arg0);
		rootView = getView();
		btn_add = (Button) rootView.findViewById(R.id.option_btn_add);
		btn_add.setText(R.string.option_exit);
		btn_back = (Button) rootView.findViewById(R.id.option_btn_cancel);
		btn_logout = (Button) rootView.findViewById(R.id.option_btn_logout);
		//
		btn_add.setOnClickListener(this);
		btn_back.setOnClickListener(this);
		btn_logout.setOnClickListener(this);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.option_panel_exit, container,
				false);
		return wrapToPanel(view);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.option_btn_logout:
			XmppApplication.getXmppSDK(getActivity()).disconnect();
			getActivity().finish();
			dismiss();
			break;
		case R.id.option_btn_add:
			getActivity().finish();
			dismiss();
			break;
		case R.id.option_btn_cancel:
			dismiss();
			break;
		}

	}

}
